<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php 
	session_start();
 ?>




    <tr>
      <td colspan="2"><div align="center">
        <input type="submit" name="Submit" value="Đăng nhập">
         <input type="submit" name="Submit" value="Đăng ký">
      </div></td>

    </tr>
	
  </table>
<hr  size="2" align="center" color="#000066" width="210px">
  
    	<?php
	if($_POST["Submit"]=="Đăng nhập" && $_POST["email"] && $_POST ["password"])
	//co phan biet chu hoa chu thuong
	{	
		
	$email=$_POST["email"];
	$password=$_POST ["password"];	
	//Ket noi den MySQL
	$con=mysql_connect("localhost","root","") or die("Khong the ket noi voi MySQL");
	

	//Chon CSDL QLSV
	mysql_select_db("clock",$con) or die("khong ket noi CSDL duoc");
	
	//Thuc hien cau truy van
	$query="select * from khachhang where email='".$_POST["email"]."' and password='".$_POST["password"]."'";
	$result=mysql_query($query,$con);
	
	if(mysql_num_rows($result)>0)
	{
		//lay ten sinh vien
		$row = mysql_fetch_row($result);
		$hoten=$row[2];
		
		session_register("email");
		session_register("hoten");
		session_register("password");
		$_SESSION["email"]=$email;
		$_SESSION["hoten"]=$hoten;
		$_SESSION["password"]=$password;
		
		
		header("Location:index.php");
		//echo "Xin chào :".$_SESSION["tensv"];
	}
	else
	{
		echo "<div align=center > Đăng nhập không thành công. Vui lòng nhập lại.<div>";
		
	}
	
			mysql_close($con);
	}
	
?>
  





